<?php

require_once(BaseConfig::LoadClass('conecta.class.php'));

class ConectaP extends Conecta_Base {
  var $rsConeccionServidor   ;
  var $rsConeccionDB         ;
  
  function __db_connect($strGDBServer = "", $strGDBUser = "", $strGDBPass = "", $strGDBName = "") {
    $this->strTipoConexion = "PostgreSQL";
    
    global $strGDBPortP;
    if(!$strGDBPortP) $strGDBPortP = "5432";
    $strConectionString        = "";
    $strConectionString       .= "host=$strGDBServer "  ;
    $strConectionString       .= "port=$strGDBPortP "   ;
    $strConectionString       .= "dbname=$strGDBName "  ;
    $strConectionString       .= "user=$strGDBUser "    ;
    $strConectionString       .= "password=$strGDBPass ";
    
    $this->rsConeccionServidor = pg_connect ($strConectionString) or die("No puedo conectarme al servidor de datos: $strConectionString [" . pg_last_error() . "]");
    $this->rsConeccionDB = $this->rsConeccionServidor;
  }
  
  function __db_query($strConsulta) {
    return pg_query($this->rsConeccionDB, $strConsulta);
  }
  
  function __db_num_rows() {
    return pg_num_rows($this->rsResultadoConsulta);
  }
  
  /*
  function __db_insert_id() {
    return mysql_insert_id($this->rsConeccionServidor);
  }
  */
  
  function __db_fetch_assoc($rsResCon) {
    return pg_fetch_assoc($rsResCon);
  }
  
  function ConectaP($strDBServer = "", $strDBName = "", $strDBUser = "", $strDBPass = "") {
    global $strGDBServerP, $strGDBNameP, $strGDBUserP, $strGDBPassP;
    
    if(!$strDBServer) { $strDBServer = $strGDBServerP; }
    if(!$strDBName  ) { $strDBName   = $strGDBNameP  ; }
    if(!$strDBUser  ) { $strDBUser   = $strGDBUserP  ; }
    if(!$strDBPass  ) { $strDBPass   = $strGDBPassP  ; }
    
    parent::Conecta_Base($strDBServer, $strDBName, $strDBUser, $strDBPass);
  }
}

?>